<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 引用vue3的源码 -->
    <script src="https://unpkg.com/vue@next"></script>
</head>
<body>
    <div class="app"></div>
    
</body>
<script>
    const app = Vue.createApp({
        data(){
            return{
                message:'jspang.com'
            }
        },
        methods: {
            clickItem(){
                this.message = this.message == 'jspang.com'?'技术胖':'jspang.com'
            }
        },
        //可以直接用三元运算符来进行条件判断
        //也可以用v-if
        template:`
            <h2 
                :class="message == 'jspang.com'?'one':'two'"
                @click="clickItem"
            >
                {{message}}
            </h2>
            <h2 
                @click="clickItem"
                v-if="message =='技术胖'" class="one"
            >
                {{message}}
            </h2>
        `
    })
    app.mount('.app')
</script>
<style>
    .one{
        color: red;
    }
    .two{
        color: green;
    }
</style>
</html>